package niuke;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class HJ30 {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.next();
        String str2 = scanner.next();

        // 1. 合并两个字符串
        String tempResult1 = mergeTwoStr(str1, str2);
        System.out.println(tempResult1);

        // 2. 对字符串进行排序
        String tempResult2 = sortStr(tempResult1);
        System.out.println(tempResult2);

        // 3. 转换操作
        String result = convertStr(tempResult2);
        System.out.println(result);
    }

    private static String convertStr(String tempResult2) {
        //hash 保存十六进制反转的对应表， 空间换时间
        Map<Character, Character> map = new HashMap<Character, Character>() {{
            put('0', '0');
            put('1', '8');
            put('2', '4');
            put('3', 'C');
            put('4', '2');
            put('5', 'A');
            put('6', '6');
            put('7', 'E');
            put('8', '1');
            put('9', '9');
            put('a', '5');
            put('b', 'D');
            put('c', '3');
            put('d', 'B');
            put('e', '7');
            put('f', 'F');
            put('A', '5');
            put('B', 'D');
            put('C', '3');
            put('D', 'B');
            put('E', '7');
            put('F', 'F');
        }};
        char[] chars = tempResult2.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            chars[i] = map.getOrDefault(tempResult2.charAt(i), tempResult2.charAt(i));
        }
        return new String(chars);
    }

    private static String sortStr(String tempResult1) {
        char[] charArray = tempResult1.toCharArray();
        int strLength = tempResult1.length();
        char[] evenCharArr; // 存放偶数索引位置上的字符数组
        char[] oddCharArr;  // 存放奇数索引位置上的字符数组
        if (strLength % 2 == 0) {
            evenCharArr = new char[strLength / 2];
        } else {
            evenCharArr = new char[(strLength / 2) + 1];
        }
        oddCharArr = new char[strLength / 2];
        String temp1 = "";
        String temp2 = "";
        for (int i = 0; i < charArray.length; i++) {
            if (i % 2 == 0) {
                temp1 += charArray[i];
            } else {
                temp2 += charArray[i];
            }
        }
        char[] c1 = temp1.toCharArray();
        char[] c2 = temp2.toCharArray();
        System.arraycopy(c1, 0, evenCharArr, 0, c1.length);
        System.arraycopy(c2, 0, oddCharArr, 0, c2.length);
        Arrays.sort(evenCharArr);
        Arrays.sort(oddCharArr);

        // 放回原来的数组中
        for (int i = 0, j = 0, k = 0; i < charArray.length; i++) {
            if (i % 2 == 0) {
                charArray[i] = evenCharArr[j];
                j++;
            } else {
                charArray[i] = oddCharArr[k];
                k++;
            }
        }
        return new String(charArray);
    }

    private static String mergeTwoStr(String str1, String str2) {
        return str1 + str2;
    }

}
